package dispinfo;

import java.util.Timer;

import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

import dispinfo.gismeteo.GismeteoProvider;

public class DipsInfoMidlet extends MIDlet
{
	private static boolean alreadyStarted = false;
	private static Provider currentProvider = new GismeteoProvider();
	
	private static DispInfoCanvas canvas = null;
	private static Display display = null;
	private static Timer timer = new Timer(); 

	public DipsInfoMidlet()
	{
		
	}

	protected void destroyApp(boolean arg0) throws MIDletStateChangeException
	{
	}

	protected void pauseApp()
	{
	}

	protected void startApp() throws MIDletStateChangeException
	{
		if (!alreadyStarted)
		{
			alreadyStarted = true;
			display = Display.getDisplay(this);
			canvas = new DispInfoCanvas();
			display.setCurrent(canvas);
			
			
			canvas.setProvider(currentProvider);
			
			currentProvider.startRequestTimer(timer);
		}
	}
	
	public static void onProviderNewData(Provider provider)
	{
		if (provider == DipsInfoMidlet.currentProvider) canvas.repaint();
	}
}
